package com.qianfeng.plateform2203.zuul.utils;

import com.netflix.zuul.context.RequestContext;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ZuulUtils {
    public static void sentErrorRespons(RequestContext currentContext,String msg){
        // 请求有问题，不允许请求继续发给后面的微服务了
        currentContext.setSendZuulResponse(false);

        final HttpServletResponse response = currentContext.getResponse();
        response.setContentType("text/html;charset=utf-8");
        try {
            response.getWriter().println(msg);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
